#include "apue.h"
int main() {
	int pid;// = fork()
	if ((pid = fork()) < 0)
		err_sys("fork error");
	else if (pid == 0) {
		if ((pid = fork()) < 0)
			err_sys("fork error");
		else if (pid == 0) {
			sleep(2);
			printf("second chlid, pid = %d, ppid = %d\n", getpid(), getppid());
			exit(0);
		} else {
			printf("first child, pid = %d, ppid = %d\n", getpid(), getppid());
			exit(0);
		}
	}
	printf("parent, pid = %d , ppid = %d\n", getpid(), getppid());
	getchar();
    return 0;
}
